#include "example.h"

net_fnc_s opcd TestClass::accept_connect(int status_init)
{	status = status_init;
	return 0;
}

// returns 'length' of 'str'
net_fnc opcd TestClass::get_length( net_out int & length, const std::string & str ) 
{	
	length = str.length();
	return 0;
}

//returns length of vector 
net_fnc opcd TestClass::get_vect_length( net_out int & length, const std::vector<trivTypes> & vec )
{
	length = vec.size();
	return 0;
}

	// multiplies 'a' and 'b' and returns 'result'
net_fnc opcd TestClass::multiply( double a, double b, net_out double & result ) 
{	
	result = a * b;
	return 0;
}

// multiplies 'a' and 'b' and returns 'result'
net_fnc opcd TestClass::add_one( net_inout int & number ) 
{	
	number++;
	return 0;
}

// sets 'status' variable
net_fnc opcd TestClass::set_status( net_out int & old_status, int new_status ) 
{	old_status = status;
	status = new_status;
	return 0;
}

net_fnc opcd TestClass::set_birth_date(net_in std::vector< birth_date > & birt_d) {

	return 0;
}

net_fnc opcd TestClass::cmplx_meth_in(net_in std::vector<cmplx> & smthg_in, net_in color & colorstruct, net_in int & number_in) 
{

	return 0;

}

net_fnc opcd TestClass::cmplx_meth(net_out std::vector<cmplx> & smthg_out,  net_out color & colorstruct, net_out int & number_out)
{
	colorstruct.col1=123;
	colorstruct.col2=456;
	colorstruct.tt.a=1.235;
	colorstruct.tt.b=1;
	colorstruct.tt.c='a';
	
	for (int i=0;i<10;i++)
	{
		cmplx _t;

		_t.label.assign("hi ");
		_t.value=i+0.1;
		_t.number=100+i;	
		_t.structure.num1=110+i;
		_t.structure.num2=220+i;
		_t.structure.label.assign("structura easy ");
		_t.structure.somecolor.col1=1;
		_t.structure.somecolor.col2=2;
		_t.structure.somecolor.tt.a=1;
		_t.structure.somecolor.tt.b=2;
		_t.structure.somecolor.tt.c='c';

		
		for (int j=0;j<10;j++) 
		{
			color _color;
			_color.col1=1+j+i;
			_color.col2=2+j+1;
			_color.tt.a=1;
			_color.tt.b=2;
			_color.tt.c='a';
			_t.structure.colorVector.push_back(_color);
		}

		smthg_out.push_back(_t);
	}
	number_out = 100;

	return 0;
}


net_fnc opcd TestClass::array_of_int(net_in std::vector<int> int_array) {

	return 0;
}

net_fnc opcd TestClass::get_string_vector( net_out std::vector<std::string> & string_vector_out ) {
	
	for (int i=0;i<10;i++)
	{
		std::string _s;

		_s.assign("hello world");
		string_vector_out.push_back(_s);
	}
	return 0;
}

net_fnc opcd TestClass::set_string_vector( net_in std::vector<std::string> & string_vector_in ) {
	
	
	return 0;
}

net_fnc opcd TestClass::set_vv_cmplx_and_trivType( net_in std::vector<std::vector<cmplx> > & vv_cmplx_in, net_in std::vector<std::vector<trivTypes> > & vv_trivTypes_in) {

	return 0;
}

net_fnc opcd TestClass::get_vv_cmplx_and_trivType( net_out std::vector<std::vector<cmplx> > & vv_cmplx_out, net_out std::vector<std::vector<trivTypes> > & vv_trivTypes_out) {

//start of cmplx vector block
	cmplx _t;
	_t.label.assign("hi ");
	_t.value=100+0.1;
	_t.number=100;	
	_t.structure.num1=110;
	_t.structure.num2=220;
	_t.structure.label.assign("structura easy ");
	_t.structure.somecolor.col1=1;
	_t.structure.somecolor.col2=2;
	_t.structure.somecolor.tt.a=1;
	_t.structure.somecolor.tt.b=2;
	_t.structure.somecolor.tt.c='c';

	for (int j=0;j<10;j++) 
	{
		color _color;
		_color.col1=1+j;
		_color.col2=2+j;
		_color.tt.a=1;
		_color.tt.b=2;
		_color.tt.c='a';
		_t.structure.colorVector.push_back(_color);
	}
	
	std::vector<cmplx> help_vector;
	help_vector.push_back(_t);
	vv_cmplx_out.push_back(help_vector);
// end of cmplx vector block

//start of trivTypesBlock
	for (int j=0; j<10; j++) {
		std::vector<trivTypes> vt;
		for (int i=0; i<10; i++) {
			trivTypes _tt;
			_tt.a=i+1;
			_tt.b=i+2;
			_tt.c='d';			
			vt.push_back(_tt);
		}
		vv_trivTypes_out.push_back(vt);
	}
//end of trivTypes block

	return 0;
}

net_fnc opcd TestClass::set_personal_data( net_in person & person_in_out ) 
{
	
	return 0;	
}

net_fnc opcd TestClass::set_address( net_in address_struct & address )
{
	return 0;	
}

net_fnc opcd TestClass::calculate( net_inout calculator & calcul_in_out)
{
	if ( calcul_in_out.operation == "+" ) 
	{
		calcul_in_out.score+=calcul_in_out.number_in;
	}
	if ( calcul_in_out.operation == "-" ) 
	{
		calcul_in_out.score-=calcul_in_out.number_in;
	}
	if ( calcul_in_out.operation == "*" ) 
	{
		calcul_in_out.score*=calcul_in_out.number_in;
	}
	if ( calcul_in_out.operation == "/" ) 
	{
		calcul_in_out.score/=calcul_in_out.number_in;
	}
	if ( calcul_in_out.operation == "=" ) 
	{
		calcul_in_out.score=calcul_in_out.score;
	}

	return 0;
}
